﻿@{
    Layout = null;
    ViewData["Title"] = "changeselect";
}

<script src="~/js/vue.js"></script>
<script src="~/js/axios.js"></script>
<script src="~/element-ui/lib/index.js"></script>
<link rel="stylesheet" href="~/element-ui/lib/theme-chalk/index.css" />
<div id="add">
    <el-form v-if="item2">
        <el-table :data="tableData"
                  :border="true" style="width: 100%">
            <el-table-column prop="first_kind_name"
                             label="I级机构"
                             width="180">
            </el-table-column>
            <el-table-column prop="second_kind_name"
                             label="II级机构"
                             width="180">
            </el-table-column>
            <el-table-column prop="third_kind_name"
                             label="III机构"
                             width="180">
            </el-table-column>
            <el-table-column prop="salary_standard_name"
                             label="薪酬标准"
                             width="180">
            </el-table-column>
            <el-table-column prop="human_name"
                             label="名字"
                             width="180">
            </el-table-column>
            <el-table-column label="审核">
                <template slot-scope="scope">
                    <el-button size="mini"
                               v-on:click="handleEdit(scope.row)">审核</el-button>
                </template>
            </el-table-column>
        </el-table>

        @*    分页组件*@
        <el-pagination v-on:size-change="handleSizeChange"
                       v-on:current-change="handleCurrentChange"
                       :current-page="currentPage"
                       :page-sizes="[3, 6, 9, 12]"
                       :page-size="pageSize"
                       layout="total, sizes, prev, pager, next, jumper"
                       :total="rows">
        </el-pagination>
    </el-form>

    <el-form ref="form" :model="form" label-width="110px" v-if="item3">
        <div id="headDiv">
            <el-button type="primary" round=round size="mini" v-on:click="tijiao()">提交</el-button>
            <el-button type="primary" round=round size="mini" v-on:click="fanhu()">返回</el-button>
        </div>
        <el-row>
            <el-col :offset="17">
                <template>
                    <el-radio v-model="radio" label="1">通过</el-radio>
                    <el-radio v-model="radio" label="2">不通过</el-radio>
                </template>
            </el-col>
        </el-row>
        <el-input v-model="form.mch_id" :disabled="true" v-if="false"></el-input>
        @*第一行*@
        <el-row>
            <el-col :span="5">
                <el-form-item label="档案编号" size="mini">
                    <el-input v-model="form.human_id" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="姓名" size="mini">
                    <el-input v-model="form.human_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        @*第二行*@
        <el-row>
            <el-col :span="5">
                <el-form-item label="原一级机构" size="mini">
                    <el-input v-model="form.first_kind_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="原二级机构" size="mini">
                    <el-input v-model="form.second_kind_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="原三级机构" size="mini">
                    <el-input v-model="form.third_kind_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        @*第三行*@
        <el-row>
            <el-col :span="5">
                <el-form-item label=" 原职位分类 " size="mini">
                    <el-input v-model="form.major_kind_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="原职位名称" size="mini">
                    <el-input v-model="form.major_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="原薪酬标准" size="mini">
                    <el-input v-model="form.salary_standard_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="原薪酬总额" size="mini">
                    <el-input v-model="form.salary_sum" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        @*第四行*@
        <el-row>
            <el-col :span="5">
                <el-form-item label="新一级机构" size="mini">
                    <el-input v-model="form.new_first_kind_id" v-if="false"></el-input>
                    <el-input v-model="form.new_first_kind_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="新二级机构" size="mini">
                    <el-input v-model="form.new_second_kind_id" v-if="false"></el-input>
                    <el-input v-model="form.new_second_kind_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="新三级机构" size="mini">
                    <el-input v-model="form.new_third_kind_id" v-if="false"></el-input>
                    <el-input v-model="form.new_third_kind_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        @*第五行*@
        <el-row>
            <el-col :span="5">
                <el-form-item label=" 新职位分类 " size="mini">
                    <el-input v-model="form.new_major_kind_id" v-if="false"></el-input>
                    <el-input v-model="form.new_major_kind_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="新职位名称" size="mini">
                    <el-input v-model="form.new_major_id" v-if="false"></el-input>
                    <el-input v-model="form.new_major_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="新薪酬标准" size="mini">
                    <el-input v-model="form.new_salary_standard_id" v-if="false"></el-input>
                    <el-input v-model="form.new_salary_standard_name" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="新薪酬总额" size="mini">
                    <el-input v-model="form.new_salary_sum" :disabled="true"></el-input>
                    
                </el-form-item>
            </el-col>
        </el-row>
        @*第六行*@
        <el-row>
            <el-col :span="5">
                <el-form-item label="登记人" size="mini">
                    <el-input v-model="form.register" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="登记时间" size="mini">
                    <el-input v-model="form.regist_time" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="复核人" size="mini">
                    <el-input v-model="form.checker" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="复核时间" size="mini">
                    <el-input v-model="form.check_time" :disabled="true"></el-input>
                    <el-input v-model="form.major_change_amount" v-if="false"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        @*第七行*@
        <el-row>
            <el-col :span="20">
                <el-form-item label="调动原因" size="mini">
                    <el-input type="textarea" :rows="5" v-model="form.change_reason" :disabled="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="20">
                <el-form-item label="审核通过意见" size="mini">
                    <el-input type="textarea" :rows="5" v-model="form.check_reason"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
    </el-form>
</div>


<script type="text/javascript">
    new Vue({
        el: "#add",
        data: {
            tableData: [],
            pageSize: 3,
            currentPage: 1,
            rows: 1,
            form: {
                huf_id: "",
                mch_id: "",
                //档案编号
                human_id: "",
                //姓名
                human_name: "",
                //原一/二/三级机构名称
                first_kind_name: "",
                second_kind_name: "",
                third_kind_name: "",
                //原职位分类/职位名称/薪酬标准名称
                major_kind_name: "",
                major_name: "",
                salary_standard_name: "",
                //原薪酬总额
                salary_sum: "",
                //新一/二/三级机构id
                new_first_kind_id: "",
                new_second_kind_id: "",
                new_third_kind_id: "",
                //新一/二/三级机构名称
                new_first_kind_name: "",
                new_second_kind_name: "",
                new_third_kind_name: "",
                //新职位分类/职位名称/薪酬标准id
                new_major_kind_id: "",
                new_major_id: "",
                new_salary_standard_id: "",
                //新职位分类/职位名称/薪酬标准名称
                new_major_kind_name: "",
                new_major_name: "",
                new_salary_standard_name: "",
                //新薪酬总额
                new_salary_sum: "",
                //登记人/复核人
                register: "",
                checker: sessionStorage.getItem('userName'),
                //登记时间/复核时间
                regist_time: "",
                check_time: "",
                //调动原因/审核通过意见
                change_reason: "",
                check_reason: "",
               
                major_change_amount:"",
            },
            item2: true,
            item3: false,
            radio: '1',
        },
        methods: {
            //分页查询职位调动表
            fenyeselect() {
                axios.get('/Major_change/FenYeSelect2', {
                    params: {
                        pageSize: this.pageSize,
                        currentPage: this.currentPage,
                    }
                }).then(res => {
                    console.info("data", res)
                    this.tableData = res.data.dt;
                    this.rows = res.data.rows;
                });
                
            },
            //每页显示数改变事件
            handleSizeChange: function(val) {
                this.pageSize = val;
                this.fenyeselect();
            },
            //页码改变事件
            handleCurrentChange: function(val) {
                this.currentPage = val;
                this.fenyeselect();
            },
            //审核
            handleEdit(row) {
                this.item2 = false;
                this.item3 = true;
                //id
                this.form.mch_id = row.mch_id;
                //档案编号
                this.form.human_id = row.human_id;
                //姓名
                this.form.human_name = row.human_name;
                //原一/二/三机构名称
                this.form.first_kind_name = row.first_kind_name;
                this.form.second_kind_name = row.second_kind_name;
                this.form.third_kind_name = row.third_kind_name;
                //原职位分类/职位名称/薪酬标准名称
                this.form.major_kind_name = row.major_kind_name;
                this.form.major_name = row.major_name;
                this.form.salary_standard_name = row.salary_standard_name;
                //原薪酬总额
                this.form.salary_sum = row.salary_sum;
                //新一/二/三机构id
                this.form.new_first_kind_id = row.new_first_kind_id;
                this.form.new_second_kind_id = row.new_second_kind_id;
                this.form.new_third_kind_id = row.new_third_kind_id;
                //新一/二/三机构名称
                this.form.new_first_kind_name = row.new_first_kind_name;
                this.form.new_second_kind_name = row.new_second_kind_name;
                this.form.new_third_kind_name = row.new_third_kind_name;
                //新职位分类/职位名称/薪酬标准名称
                this.form.new_major_kind_id = row.new_major_kind_id;
                this.form.new_major_id = row.new_major_id;
                this.form.new_salary_standard_id = row.new_salary_standard_id;
                //新职位分类/职位名称/薪酬标准名称
                this.form.new_major_kind_name = row.new_major_kind_name;
                this.form.new_major_name = row.new_major_name;
                this.form.new_salary_standard_name = row.new_salary_standard_name;
                //新薪酬总额
                this.form.new_salary_sum = row.new_salary_sum;
                //登记人/登记时间
                this.form.register = row.register;
                this.form.regist_time = row.regist_time;
                //调动原因
                this.form.change_reason = row.change_reason;
               
                //console.info(row.new_major_name)
            },
            tick() {
                var d = new Date();
                var y = d.getFullYear();
                var moth = d.getMonth() + 1;
                var date = d.getDate();
                var h = d.getHours();
                var m = d.getMinutes();
                var s = d.getSeconds();
                var hh = 20 - 1 - h;
                var mm = 60 - 1 - m;
                var ss = 60 - s;
                if (hh > 0) {
                    mm = mm + 60 * hh;
                }
                if (moth < 10) {
                    moth = "0" + moth;
                }
                if (date < 10) {
                    date = "0" + date;
                }
                if (h < 10) {
                    h = "0" + h;
                }
                if (m < 10) {
                    m = "0" + m;
                }
                if (s < 10) {
                    s = "0" + s;
                }
                if (mm < 10) {
                    mm = "0" + mm;
                }
                if (ss < 10) {
                    ss = "0" + ss;
                }
                this.form.check_time = y + " - " + moth + " - " + date + " " + h + ": " + m + ": " + s;
            },
            fanhu() {
                this.item2 = true;
                this.item3 = false;
            },
            tijiao() {
                //添加/审核通过意见/复核通过状态/复核人/复核时间
                //console.info("this.form.check_reason:", this.form.check_reason);
                //判断是否通过--/通过为‘1’不通过‘2’
                if (this.radio == 1) {
                    //修改人力资源档案
                    axios.post('/Major_change/human_fileUpdate', {
                        human_id: this.form.human_id,
                        //新一/二/三级机构编号
                        first_kind_id: this.form.new_first_kind_id,
                        second_kind_id: this.form.new_second_kind_id,
                        third_kind_id: this.form.new_third_kind_id,
                        //新一/二/三级机构名称
                        first_kind_name: this.form.new_first_kind_name,
                        second_kind_name: this.form.new_second_kind_name,
                        third_kind_name: this.form.new_third_kind_name,
                        //新职位分类/职位编号/薪酬标准ID
                        human_major_kind_id: this.form.new_major_kind_id,
                        human_major_id: this.form.new_major_id,
                        salary_standard_id: this.form.new_salary_standard_id,
                        //新职位分类/职位名称/薪酬标准名称
                        human_major_kind_name: this.form.new_major_kind_name,
                        human_major_name: this.form.new_major_name,
                        salary_standard_name: this.form.new_salary_standard_name,
                        ////新薪酬总额
                        salary_sum: this.form.new_salary_sum,
                        //major_change_amount: this.form.major_change_amount,
                    }).then(res => {

                    });
                }
                axios.post('/Major_change/Update', {
                    //id
                    mch_id: this.form.mch_id,
                    //复核人-/复核时间-/审核通过意见-/复核通过状态
                    checker: this.form.checker,
                    check_time: new Date(),
                    check_reason: this.form.check_reason,
                    check_status: this.radio,
                }).then(res => {
                    if (res.data > 0) {
                        alert(" 审核完毕");
                        this.form.check_reason = "";
                        this.item2 = true;
                        this.item3 = false;
                        this.fenyeselect();
                    }
                });
            },
        },
        mounted() {
            this.fenyeselect();
            window.onload = this.tick;
            var out = window.setInterval(this.tick, 1000);
        }
    })
</script>